package com.choosefine.it.cprivilege.controller;

import com.choosefine.it.base.BaseController;
import com.choosefine.it.base.dto.PageDTO;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.cprivilege.model.ExcelProcessLog;
import com.choosefine.it.cprivilege.service.ExcelProcessService;
import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Comments：excel导入导出记录管理
 * Author：毛俊
 * Create Date：2017/3/11
 * Modified By：
 * Modified Date：
 * Why & What is modified：
 * Version：v1.0
 */
@RestController
@Api(value = "excel导入导出记录管理",description = "毛俊")
@RequestMapping("/excelProcess")
public class ExcelProcessController extends BaseController{


    @Autowired
    ExcelProcessService excelProcessService;

    @ApiOperation(value = "获取excel导入导出记录", notes = "控制台—批量导入进程管理",response = ExcelProcessLog.class)
    @ApiImplicitParams({@ApiImplicitParam(name = "pageNum",value = "起始页",required = false,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "页大小",required = false,dataType = "int",paramType = "query")})
    @RequestMapping(value = "/getExcelProcessLog",method = RequestMethod.GET,produces = "application/json")
    public String getExcelProcessLog(Integer pageNum, Integer pageSize) {
        String result = null;
        PageDTO pageDTO = new PageDTO();
        pageDTO.setPageNum(pageNum);
        pageDTO.setPageSize(pageSize);
        Page<ExcelProcessLog> list = excelProcessService.getExcelProcessLog(pageDTO);
        if(list.size() > 0){
            result=responseSuccess(list.toPageInfo(), ResultCode.SUCCESS,ResultCode.MSG_QUERY_SUCCESS);
        }else {
            result=responseFail(ResultCode.MSG_ERROR);
        }
        return result;
    }
}
